import AI from "../services/ai.js";
import User from "../models/user.js";
import Result from "../utils/result.js";
const AIController = {
    async AIParseData(req,res){

        try{
            
            const {userId,userPrompt} = req.body;
            const user=await User.findByPk(userId);
            if(!user){
                res.status(404).json(Result.notfound("User not found"))
            }
            
            const result = await AI.AIParseData(userId,userPrompt);
            if(!result){
                console.log(result);
                res.status(500).json(Result.error('Failed to parse data'));
            }
            res.status(200).json(Result.success(result,'Data parsed successfully'));
        } catch(error){
            res.status(500).json(Result.error(error.message))
        }
        
    },

    // async AIMakeReport(req,res){
    //     try{
    //         const {userId,period} = req.body;
    //         const user=await User.findByPk(userId);

    //         if(!user){
    //             res.status(404).json(Result.notfound("User not found"))
    //         }
            
    //         const result = await AI.AIMakeReport(userId,period);
            
    //         if(!result){
    //             res.status(500).json(Result.error("Failed to generate report"))
    //         }

    //         res.status(200).json(Result.success(result,'Report generated successfully'));
    //     } catch(error){
    //         res.status(500).json(Result.error(error.message))
    //     }

    // }

}

export default AIController;